/*
 * 
 *  $Author: nfelipe$
 * 
 *  Copyright (c) 2011 by PROS Revenue Management.  All Rights Reserved.
 *  This software is the confidential and proprietary information of
 *  PROS Revenue Management ("Confidential Information").
 *  You shall not disclose such Confidential Information and shall use it
 *  only in accordance with the terms of the license agreement you entered
 *  into with PROS.
 * 
 */

package javaapplication2;

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;

public class jwmen2 extends java.applet.Applet {
    Image i;
    int width = 200;
    int height = 200;
    public void init () {
        byte[] pixels = new byte [width*height];
	int arraySize = 3;
        Color colorArray[] = new Color [arraySize];
	colorArray[0] = Color.green;
	for (int i=1;i<arraySize;i++)
	    colorArray[i]=colorArray[i-1].darker();
        byte reds[]   = new byte[arraySize];
        byte greens[] = new byte[arraySize];
        byte blues[]  = new byte[arraySize];
        for (int i=0;i<arraySize;i++) {
            reds[i]   = (byte)colorArray[i].getRed();
            greens[i] = (byte)colorArray[i].getGreen();
            blues[i]  = (byte)colorArray[i].getBlue();
        }
        for (int index=0,y=0;y<height;y++)
            for (int x=0;x<width;x++)
                pixels[index++] = (byte)(x%arraySize);
        i = createImage (new MemoryImageSource (width, height,
            new IndexColorModel (8, arraySize, reds, greens, blues),
            pixels, 0, width));
	setFont (new Font ("TimesRoman", Font.BOLD | Font.ITALIC, 32));
    }
    public void paint (Graphics g) {
        g.drawImage (i, 0, 0, this);
	g.drawString ("JavaWorld2", 30, 80);
    }

    public static void main(String arg[]) throws IOException{
        int width = 100, height = 16;
        BufferedImage buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = buffer.createGraphics();
        g.setColor(new Color(204, 206, 212, 255));
        g.fillRect(0, 0, width, height);

        g.setColor(new Color(59, 0, 0, 255));
        g.setFont(new Font ("Arial", Font.PLAIN, 11));
        g.drawString("Workteam PO asdf", 10, 10);
        
        File outputfile = new File("imagewithtext.png");
        ImageIO.write(buffer, "png", outputfile);
    }
}